//
//  SecondViewController.m
//  Clase4Demo
//
//  Created by Santiago Fontanarrosa on 6/20/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "SecondViewController.h"
#import "WebViewController.h"

@interface SecondViewController ()

@property (nonatomic,retain) NSString *urlStr;
@end

@implementation SecondViewController

@synthesize urlStr = _urlStr;
@synthesize textField = _textField;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Second", @"Second");
        self.tabBarItem.image = [UIImage imageNamed:@"second"];
    }
    return self;
}
							
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

-(void)dealloc
{
    self.textField = nil;
    self.urlStr = nil;
    [super dealloc];
}

-(IBAction)submitClicked:(id)sender
{
    WebViewController *webView = [[[WebViewController alloc] init] autorelease];
    webView.urlStr = self.urlStr;
    [self.navigationController pushViewController:webView animated:YES];    
}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.textField resignFirstResponder];
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    self.urlStr = textField.text;
}

@end
